﻿<%@ Page Language="C#" MasterPageFile="~/Search/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Search_Company_Default" Title="无标题页" %>

<%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<script type="text/javascript">
        var template = '<span style="color:{0};">{1}</span>';

        var Shenhe = function (value) {
            if(value==0){return String.format(template,'red', '未审');}
            if(value==1){return String.format(template,'green', '同意');}
            if(value==2){return String.format(template,'blue', '退回');}
        }
    </script>
     <ext:Store ID="StoreCompany" runat="server">
    <Reader>
        <ext:JsonReader ReaderID="companyid">
            <Fields>
                <ext:RecordField Name="companyid" Type="String"></ext:RecordField>
                <ext:RecordField Name="companyname" Type="String"></ext:RecordField>
                <ext:RecordField Name="companyaddress" Type="String"></ext:RecordField>
                <ext:RecordField Name="elecricname" Type="String"></ext:RecordField>
                <ext:RecordField Name="tradename" Type="String"></ext:RecordField>
                <ext:RecordField Name="deptname" Type="String"></ext:RecordField>
            </Fields>
        </ext:JsonReader>
    </Reader>
    </ext:Store>
        <ext:Store ID="StoreDetail" OnRefreshData="StoreDetail_onRefresh" runat="server">
        <Reader>
            <ext:JsonReader ReaderID="guid">
                <Fields>
                    <ext:RecordField Name="guid" Type="String"></ext:RecordField>
                    <ext:RecordField Name="companyid" Type="String"></ext:RecordField>
                    <ext:RecordField Name="companyname" Type="String"></ext:RecordField>
                    <ext:RecordField Name="dept_master_status"  Type="Int"></ext:RecordField>
                    <ext:RecordField Name="manager_status" Type="Int"></ext:RecordField>
                    <ext:RecordField Name="intime" Type="Date"></ext:RecordField>
                </Fields>
            </ext:JsonReader>
        </Reader>
      <BaseParams>
            <ext:Parameter 
            Name="companyid" 
            Value="#{GridPanel1}.getSelectionModel().hasSelection() ? #{GridPanel1}.getSelectionModel().getSelected().id : -1"
            Mode="Raw">                    
            </ext:Parameter>
        </BaseParams>
    </ext:Store>
     <ext:ViewPort ID="ViewPort1" runat="server">
    <Body>
    <ext:RowLayout ID="RowLayout1" runat="server" Split="true">
                <ext:LayoutRow RowHeight="0.1">
    <ext:FormPanel ID="FormPanel1" runat="server" BodyStyle="padding:5px;" ButtonAlign="Right"
        Frame="true" >
        <Body>
            <ext:ContainerLayout ID="ContainerLayout1" runat="server">
                <ext:Panel ID="Panel1" runat="server">
                    <Body>
                    <table style="width:100%;">
                        <tr>
                            <td style="text-align:left;">
                            客户号：
                            <ext:TextField ID="tfcompanyid"  runat="server"></ext:TextField>
                            客户名称：
                            <ext:TextField ID="tfcompanyname" runat="server" ></ext:TextField></td> 
                            <td style="text-align:left;">
                               <ext:Button ID="BTNsearch" Text="查询" runat="server" Icon="BellGo">
                                    <AjaxEvents>
                                        <Click OnEvent="Search">
                                        
                                        </Click>
                                    </AjaxEvents>
                                </ext:Button>
                            </td>
                        </tr>
                    </table>
                    </Body>
                </ext:Panel>
            </ext:ContainerLayout>
        </Body>
    </ext:FormPanel>
    </ext:LayoutRow>
 <ext:LayoutRow RowHeight="0.4">
   
    <ext:GridPanel ID="GridPanel1" Height="300" Title="客户查询结果" Frame="true" StoreID="StoreCompany" runat="server">
    <ColumnModel>
        <Columns>
            <ext:Column ColumnID="companyid" DataIndex="companyid" Header="用户号"></ext:Column>
            <ext:Column ColumnID="companyname" DataIndex="companyname" Header="户名"></ext:Column>
            <ext:Column ColumnID="companyaddress" DataIndex="companyaddress" Header="地址"></ext:Column>
            <ext:Column ColumnID="electricname" DataIndex="electricname" Header="用电类别"></ext:Column>
            <ext:Column ColumnID="tradename" DataIndex="tradename" Header="行业类别"></ext:Column>
            <ext:Column ColumnID="deptname"  DataIndex="deptname" Header="所属部门"></ext:Column>
        </Columns>
    </ColumnModel>
     <SelectionModel>
        <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true">
            <Listeners>
                <RowSelect Handler="#{StoreDetail}.reload()" Buffer="250"  />
            </Listeners>
        </ext:RowSelectionModel>
    </SelectionModel>
    <LoadMask ShowMask="true" />
    </ext:GridPanel>
</ext:LayoutRow>
 <ext:LayoutRow RowHeight="0.5">

     <ext:GridPanel ID="GridPanel2"   Frame="true" StoreID="StoreDetail" Height="300" Title="客户诚信档案" runat="server">
            <ColumnModel>
                <Columns>
                    <ext:Column ColumnID="companyid" DataIndex="companyid" Header="户号"></ext:Column>
                    <ext:Column ColumnID="companyname" DataIndex="companyname" Header="户名"></ext:Column>
                    <ext:Column ColumnID="guid" DataIndex="guid" Hidden="true"></ext:Column>
                    <ext:Column ColumnID="dept_master_status" DataIndex="dept_master_status" Header="部门领导">
                        <Renderer Fn="Shenhe" />
                    </ext:Column>
                    <ext:Column ColumnID="manager_status" DataIndex="manager_status" Header="公司领导">
                        <Renderer Fn="Shenhe" />
                    </ext:Column>
                    <ext:Column ColumnID="intime" DataIndex="intime" Header="时间">
                        <Renderer Fn="Ext.util.Format.dateRenderer('Y-m-d')" />
                    </ext:Column>
                    <ext:CommandColumn ColumnID="Apply" Header="申请">
                        <Commands>
                            <ext:GridCommand CommandName="Apply" Icon="ApplicationGet" >
                                <ToolTip  Text="申请查询"/>
                            </ext:GridCommand>
                        </Commands>
                    </ext:CommandColumn>
                </Columns>
            </ColumnModel>
             <AjaxEvents>
                <Command OnEvent="ApplySub">
                    <ExtraParams>
                        <ext:Parameter Name="id" Value="record.data.guid" Mode="Raw">
                        </ext:Parameter> 
                    </ExtraParams>
                </Command>
             </AjaxEvents>
            <LoadMask ShowMask="true" />
         </ext:GridPanel>
         </ext:LayoutRow>
    </ext:RowLayout>
    </Body>
</ext:ViewPort>
    <ext:Window ID="Window1"  Modal="true"  Width="200" Height="150" Closable="false" runat="server" Resizable="false" ShowOnLoad="false" Collapsible="false" Icon="BuildingGo" Title="查询申请:原因">
        <Body>
            <ext:FormPanel runat="server" ID="ApplyForm">
                <Body>
                <ext:ContainerLayout runat="server" ID="containter">
                    <ext:Panel ID="Panel2" runat="server" >
                        <Body>
                        <table style="width:100%">
                            <tr>
                                <td>
                                <ext:Hidden ID="tfhiddenid" runat="server" ></ext:Hidden>
                                <ext:TextArea runat="server" Width="180" ID="tfreason"></ext:TextArea>
                                </td>
                            </tr>
                        </table> 
                        </Body>
                    </ext:Panel>
                </ext:ContainerLayout>
                </Body>
                <Buttons>
                    <ext:Button runat="server" ID="SubApply" Text="提交">
                        <AjaxEvents>
                            <Click OnEvent="Sub">                        
                            </Click>
                        </AjaxEvents>
                    </ext:Button>
                    <ext:Button runat="server" ID="Button2" Text="撤销">
                        <AjaxEvents>
                            <Click OnEvent="Cancel">                        
                            </Click>
                        </AjaxEvents>
                    </ext:Button>
                </Buttons>
            </ext:FormPanel>
        </Body>
    </ext:Window>
</asp:Content>

